package model

import (
	"fmt"
	"time"

	"../pkg/settings"
)

/**
	auth:xiaohan
 */

type Auth struct {
	Id          int64
	UserName    string    `xorm:"varchar(50) notnull unique 'name'"`
	Pwd         string    `xorm:"varchar(100) 'pwd'"`
	CreatedTime time.Time `xorm:"createdTime"`
	UpdatedTime time.Time `xorm:"updatedTime"`
}

func CheckAuth(username, password string) bool {
	user, err := settings.MasterDB.Where("name = ?", username).And("pwd = ?", password).Desc("id").Get(&Auth{})
	if err != nil {
		fmt.Println(err)
		return false
	}
	return user
}
